package com.earn.utils;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteDatabase.CursorFactory;

public class DatabaseHelper extends SQLiteOpenHelper{
	
	private static final int VERSION = 1;
	
	private static final String DATABASE_NAME = "earn.db";
	private static final String CREATE_TABLE_TESTINFO = "create table IF NOT EXISTS tb_migrate_test(tid integer primary key autoincrement,"
			+ "name varchar(100),description varchar(500),answerA varchar(40),answerB varchar(40),answerC varchar(40),answerD varchar(40),answerE varchar(40))";
	private static final String CREATE_TABLE_STATISTIC = "create table IF NOT EXISTS tb_statistic(sid integer primary key autoincrement,"
			+ "type varchar(100),answerA integer,answerB integer,answerC integer,answerD integer,answerE integer)";
	private static final String CREATE_TABLE_MIGRATEPOLICY = "create table IF NOT EXISTS tb_migrate_policy(cid integer primary key autoincrement,"
			+ "country varchar(40),policy varchar(10000))";
	private static final String CREATE_TABLE_HOUSINGRESOURCES = "create table IF NOT EXISTS tb_housing_resources(hid integer primary key autoincrement,"
			+ "country varchar(40),housing_resouce varchar(10000))";
//	private static final String TABLE_PIC = "pic";
//	private static final String TITLE = "title";
//	private static final String BODY = "body";
	
	public DatabaseHelper(Context context, String name, CursorFactory factory,
			int version) {
		super(context, name, factory, version);
	}
	
	public DatabaseHelper(Context context,String name){
		this(context, name, VERSION);
	}
	
	public DatabaseHelper(Context context, String name,int version){
		this(context,name,null,version);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
//		System.out.println("create a database");
//		String table_wiki = "CREATE TABLE IF NOT EXISTS "+ TABLE_EARN + " (id INTEGER PRIMARY KEY autoincrement,wname VARCHAR,pname VARCHAR,xray VARCHAR,yray VARCHAR,wcomments VARCHAR,plongitude VARCHAR,platitude VARCHAR,date VARCHAR);";
//		db.execSQL(table_wiki);
		
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		db.execSQL("DROP TABLE if EXISTS earn.db");
		onCreate(db);
//		System.out.println("upgrade a database");
		
	}

}
